<?php

namespace App\Models\Sys;

use App\Models\Goods\Goods;
use App\Models\User\User;
use Illuminate\Database\Eloquent\Model;

class Exchange extends Model
{

    protected $table = 'jxt_sys_exchange';

    const CREATED_AT = 'create_at';
    const UPDATED_AT = null;

    public function fromDateTime($value){
        return strtotime(parent::fromDateTime($value));
    }

    public function user()
    {
        return $this->belongsTo(User::class,'user_id','id');
    }

    public function address()
    {
        return $this->belongsTo(Address::Class);
    }

    public function goods()
    {
        return $this->belongsTo(Goods::Class,'goods_id','id')->withTrashed();
    }

    public function express()
    {
        return $this->hasOne(Express::Class,'exchange_id','id');
    }
}
